package com.gitee.wsl.collections.bag.api


/**
 * Defines a type of `Bag` that maintains a sorted order among
 * its unique representative members.
 *
 * @param <E> the type of elements in this bag
 * @since 2.0
</E> */
interface SortedBag<E> : Bag<E> {
    /**
     * Returns the comparator associated with this sorted set, or null
     * if it uses its elements' natural ordering.
     *
     * @return the comparator in use, or null if natural ordering
     */
    val comparator : Comparator<E>

    /**
     * Returns the first (lowest) member.
     *
     * @return the first element in the sorted bag
     */
    fun first(): E?

    /**
     * Returns the last (highest) member.
     *
     * @return the last element in the sorted bag
     */
    fun last(): E?
}
